#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll absw(ll x) {
	return (x < 0 ? -x : x);
}
void sol() {
	ll a, b;
	cin >> a >> b;
	if (a < b)
		swap(a, b);
	if (a * b <= 0)
		cout << min(absw(a + b), min(absw(a), absw(b)));
	else {
		cout << 0;
	}
	cout<<'\n';
}
int main() {
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	ll t;
	cin >> t;
	while (t--) {
		sol();
	}
}
